<template>
  <PermissionContainer
    :jiBieArr="[0, 1, 2]"
    :tipArr="[
      ,
      '电子卡功能只对集团和站点级别开放',
      '因为集团上关于电子卡的共享配置，此级没有配置权限',
      ,
      '您暂未启动电子卡功能',
    ]"
  >
    <div class="app-container">
      <el-form
        :model="queryParams"
        ref="queryForm"
        :inline="true"
        label-width="68px"
        class="globalSerchFormStyle"
      >
        <el-row>
          <el-col :span="6">
            <el-form-item label="手机号" prop="mobliePhone">
              <el-input
                v-model="queryParams.mobilePhone"
                placeholder="请输入客户手机号"
                clearable
                size="small"
                @keyup.enter.native="handleQuery"
                style="width: 190px"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="类型" prop="usageType">
              <el-select
                v-model="queryParams.usageType"
                placeholder="请选择消费充值类型"
                clearable
                size="small"
                style="width: 190px"
              >
                <el-option label="充值" value="+" />
                <el-option label="消费" value="-" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="时间">
              <el-date-picker
                style="width: 190px"
                v-model="dateRangeCreatedDate"
                type="datetimerange"
                value-format="yyyy-MM-dd HH:mm:ss"
                size="mini"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-row class="global_el_rowStyle" :gutter="10">
        <el-col :span="1.5">
          <el-button
            type="primary"
            icon="el-icon-search"
            size="mini"
            @click="handleQuery"
            >搜索</el-button
          >
        </el-col>
        <el-col :span="1.5">
          <el-button
            icon="el-icon-refresh"
            size="mini"
            @click="resetQuery"
            type="primary"
            plain
            >重置</el-button
          >
        </el-col>
      </el-row>
      <el-table :data="recordList">
        <af-table-column
          label="id"
          align="left"
          prop="id"
          v-if="false"
          sortable
        />
        <af-table-column
          label="油站名"
          align="left"
          prop="stationName"
          sortable
        />
        <af-table-column
          label="客户名"
          align="left"
          prop="customerName"
          sortable
        />
        <af-table-column
          label="客户手机号"
          align="left"
          prop="mobilePhone"
          sortable
        />
        <af-table-column
          label="消费充值类型"
          align="left"
          prop="usageType"
          :formatter="usageTypeFotmat"
          sortable
        />
        <af-table-column
          label="电子会员卡充值消费类型：1.微信；2.POS机"
          align="left"
          prop="payType"
          v-if="false"
          sortable
        />

        <af-table-column
          label="充值、消费金额(元)"
          align="left"
          prop="amt"
          sortable
        />

        <af-table-column
          label="余额(元)"
          align="left"
          prop="balance"
          sortable
        />
        <af-table-column
          label="充值、消费时间"
          align="left"
          prop="createTime"
          sortable
        />
        <af-table-column
          label="油站ID"
          align="left"
          prop="stationId"
          v-if="false"
          sortable
        />
      </el-table>
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
  </PermissionContainer>
</template>

<script>
import { listRecord } from "@/api/customer/record";

export default {
  name: "Dzk_Bill",
  data() {
    return {
      // 总条数
      total: 0,
      // 客户电子会员卡充值消费记录表格数据
      recordList: [],
      //查询日期
      dateRangeCreatedDate: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderNo: null,
        customerNo: null,
        customerName: null,
        usageType: null,
        payType: "dkq",
        cardOilsType: null,
        mobilePhone: null,
        levelId: this.levelId,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    usageTypeFotmat(row, column) {
      if (row.usageType === "+") {
        return "充值";
      } else if (row.usageType === "-") {
        return "消费";
      }
    },
    cardOilsTypeFotmat(row, column) {
      if (row.cardOilsType === "1") {
        return "汽油";
      } else if (row.cardOilsType === "2") {
        return "柴油";
      } else if (row.cardOilsType === "3") {
        return "非油品";
      } else if (row.cardOilsType === "4") {
        return "LNG";
      } else if (row.cardOilsType === "5") {
        return "CNG";
      }
    },
    /** 查询客户电子会员卡充值消费记录列表 */
    getList() {
      this.queryParams.levelId = this.levelId;
      listRecord(
        this.addDateRange(this.queryParams, this.dateRangeCreatedDate)
      ).then((response) => {
        this.recordList = response.rows;
        this.total = response.total;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  },
};
</script>
